import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    mode: 'community',
    visible: true,
    title: '',
    propertyInfo: {},
    communityInfo: {},
    districtInfo: {},
    videoDialog: {
      videoSrc: '',
      type: '',
      visible: false
    }
    // mock: {}
  },
  mutations: {
    SET_MODE(state, payload) {
      state.mode = payload
    },
    SET_VISIBLE(state, payload) {
      state.visible = payload
    },
    SET_COMMUNITY_INFO(state, payload) {
      state.communityInfo = payload
    },
    SET_PROPERTY_INFO(state, payload) {
      state.propertyInfo = payload
    },
    SET_DISTRICT_INFO(state, payload) {
      state.districtInfo = payload
    },
    SET_TITLE(state, payload) {
      state.title = payload
      document.title = payload
    },
    // CHANGE_INFO(state, payload) {
    //   if(payload.indexOf('安居苑') >= 0 || payload == 'load') {
    //     state.communityInfo = state.mock.communityInfo1
    //   } else if (payload.indexOf('武房二期') >= 0) {
    //     state.communityInfo = state.mock.communityInfo2
    //   }
    // },
    // UPDATA_MOCK(state, payload) {
    //   state.mock = payload
    // },
    SET_VIDEO_DIALOG(state, payload) {
      state.videoDialog = payload
    }
  },
  actions: {

  },
  getters: {
    mode: state => state.mode,
    visible: state => state.visible,
    communityInfo: state => state.communityInfo,
    title: state => state.title,
    propertyInfo: state => state.propertyInfo,
    districtInfo: state => state.districtInfo,
    videoDialog: state => state.videoDialog
  }
})
